package c.e.a.b.b.j;

import android.annotation.TargetApi;
import android.app.AppOpsManager;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.os.Binder;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import b.i.b.f;
import c.e.a.b.b.e;
import c.e.a.b.b.k.a;
import c.e.a.b.b.k.b;
import c.e.a.b.e.c.a3;
import c.e.a.b.e.c.b5;
import c.e.a.b.e.c.c3;
import c.e.a.b.e.c.d2;
import c.e.a.b.e.c.e5;
import c.e.a.b.e.c.e7;
import c.e.a.b.e.c.g6;
import c.e.a.b.e.c.m7;
import c.e.a.b.e.c.s3;
import c.e.a.b.e.c.s6;
import c.e.a.b.e.c.t3;
import c.e.a.b.e.c.u4;
import c.e.a.b.e.c.w4;
import c.e.a.b.e.c.x4;
import c.e.a.b.e.c.z2;
import c.e.a.b.e.c.z3;
import c.e.a.b.f.b.ga;
import c.e.a.b.f.b.q3;
import c.e.a.b.g.a0;
import c.e.a.b.g.g;
import c.e.a.b.g.i;
import c.e.a.b.g.j;
import c.e.a.b.g.k;
import com.huawei.hms.jos.games.ranking.RankingConst;
import com.pgl.sys.ces.out.ISdkLite;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.checkerframework.checker.nullness.compatqual.NullableDecl;

public final class d {
    public static Boolean a;
    public static Boolean b;
    public static Boolean c;
    public static Context d;
    public static Boolean e;
    public static ga f;

    public static void A(byte b, byte b2, byte b3, char[] cArr, int i) throws e5 {
        if (Q(b2) || ((b == (byte) -32 && b2 < (byte) -96) || ((b == (byte) -19 && b2 >= (byte) -96) || Q(b3)))) {
            throw e5.e();
        }
        cArr[i] = (char) ((((b & 15) << 12) | ((b2 & 63) << 6)) | (b3 & 63));
    }

    public static void B(byte b, byte b2, char[] cArr, int i) throws e5 {
        if (b < (byte) -62 || Q(b2)) {
            throw e5.e();
        }
        cArr[i] = (char) (((b & 31) << 6) | (b2 & 63));
    }

    public static void C(Bundle bundle, Object obj) {
        String str = "value";
        if (obj instanceof Double) {
            bundle.putDouble(str, ((Double) obj).doubleValue());
        } else if (obj instanceof Long) {
            bundle.putLong(str, ((Long) obj).longValue());
        } else {
            bundle.putString(str, obj.toString());
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:111:0x0250  */
    /* JADX WARNING: Missing block: B:81:0x01e5, code skipped:
            if (((java.lang.Boolean) r4).booleanValue() == false) goto L_0x024a;
     */
    /* JADX WARNING: Missing block: B:85:0x01f3, code skipped:
            if (((java.lang.Integer) r4).intValue() == 0) goto L_0x024a;
     */
    /* JADX WARNING: Missing block: B:89:0x0204, code skipped:
            if (((java.lang.Float) r4).floatValue() == 0.0f) goto L_0x024a;
     */
    /* JADX WARNING: Missing block: B:93:0x0216, code skipped:
            if (((java.lang.Double) r4).doubleValue() == 0.0d) goto L_0x024a;
     */
    public static void D(c.e.a.b.e.c.e6 r13, java.lang.StringBuilder r14, int r15) {
        /*
        r0 = new java.util.HashMap;
        r0.<init>();
        r1 = new java.util.HashMap;
        r1.<init>();
        r2 = new java.util.TreeSet;
        r2.<init>();
        r3 = r13.getClass();
        r3 = r3.getDeclaredMethods();
        r4 = r3.length;
        r5 = 0;
        r6 = 0;
    L_0x001a:
        r7 = "get";
        if (r6 >= r4) goto L_0x0049;
    L_0x001e:
        r8 = r3[r6];
        r9 = r8.getName();
        r1.put(r9, r8);
        r9 = r8.getParameterTypes();
        r9 = r9.length;
        if (r9 != 0) goto L_0x0046;
    L_0x002e:
        r9 = r8.getName();
        r0.put(r9, r8);
        r9 = r8.getName();
        r7 = r9.startsWith(r7);
        if (r7 == 0) goto L_0x0046;
    L_0x003f:
        r7 = r8.getName();
        r2.add(r7);
    L_0x0046:
        r6 = r6 + 1;
        goto L_0x001a;
    L_0x0049:
        r2 = r2.iterator();
    L_0x004d:
        r3 = r2.hasNext();
        r4 = 3;
        if (r3 == 0) goto L_0x0269;
    L_0x0054:
        r3 = r2.next();
        r3 = (java.lang.String) r3;
        r6 = r3.startsWith(r7);
        if (r6 == 0) goto L_0x0065;
    L_0x0060:
        r6 = r3.substring(r4);
        goto L_0x0066;
    L_0x0065:
        r6 = r3;
    L_0x0066:
        r8 = "List";
        r9 = r6.endsWith(r8);
        r10 = 1;
        if (r9 == 0) goto L_0x00ca;
    L_0x006f:
        r9 = "OrBuilderList";
        r9 = r6.endsWith(r9);
        if (r9 != 0) goto L_0x00ca;
    L_0x0077:
        r8 = r6.equals(r8);
        if (r8 != 0) goto L_0x00ca;
    L_0x007d:
        r8 = r6.substring(r5, r10);
        r8 = r8.toLowerCase();
        r8 = java.lang.String.valueOf(r8);
        r9 = r6.length();
        r9 = r9 + -4;
        r9 = r6.substring(r10, r9);
        r9 = java.lang.String.valueOf(r9);
        r11 = r9.length();
        if (r11 == 0) goto L_0x00a2;
    L_0x009d:
        r8 = r8.concat(r9);
        goto L_0x00a8;
    L_0x00a2:
        r9 = new java.lang.String;
        r9.<init>(r8);
        r8 = r9;
    L_0x00a8:
        r9 = r0.get(r3);
        r9 = (java.lang.reflect.Method) r9;
        if (r9 == 0) goto L_0x00ca;
    L_0x00b0:
        r11 = r9.getReturnType();
        r12 = java.util.List.class;
        r11 = r11.equals(r12);
        if (r11 == 0) goto L_0x00ca;
    L_0x00bc:
        r3 = w(r8);
        r4 = new java.lang.Object[r5];
        r4 = c.e.a.b.e.c.u4.p(r9, r13, r4);
        G(r14, r15, r3, r4);
        goto L_0x004d;
    L_0x00ca:
        r8 = "Map";
        r9 = r6.endsWith(r8);
        if (r9 == 0) goto L_0x0136;
    L_0x00d2:
        r8 = r6.equals(r8);
        if (r8 != 0) goto L_0x0136;
    L_0x00d8:
        r8 = r6.substring(r5, r10);
        r8 = r8.toLowerCase();
        r8 = java.lang.String.valueOf(r8);
        r9 = r6.length();
        r9 = r9 - r4;
        r4 = r6.substring(r10, r9);
        r4 = java.lang.String.valueOf(r4);
        r9 = r4.length();
        if (r9 == 0) goto L_0x00fc;
    L_0x00f7:
        r4 = r8.concat(r4);
        goto L_0x0101;
    L_0x00fc:
        r4 = new java.lang.String;
        r4.<init>(r8);
    L_0x0101:
        r3 = r0.get(r3);
        r3 = (java.lang.reflect.Method) r3;
        if (r3 == 0) goto L_0x0136;
    L_0x0109:
        r8 = r3.getReturnType();
        r9 = java.util.Map.class;
        r8 = r8.equals(r9);
        if (r8 == 0) goto L_0x0136;
    L_0x0115:
        r8 = java.lang.Deprecated.class;
        r8 = r3.isAnnotationPresent(r8);
        if (r8 != 0) goto L_0x0136;
    L_0x011d:
        r8 = r3.getModifiers();
        r8 = java.lang.reflect.Modifier.isPublic(r8);
        if (r8 == 0) goto L_0x0136;
    L_0x0127:
        r4 = w(r4);
        r6 = new java.lang.Object[r5];
        r3 = c.e.a.b.e.c.u4.p(r3, r13, r6);
        G(r14, r15, r4, r3);
        goto L_0x004d;
    L_0x0136:
        r3 = "set";
        r4 = r6.length();
        if (r4 == 0) goto L_0x0143;
    L_0x013e:
        r3 = r3.concat(r6);
        goto L_0x0149;
    L_0x0143:
        r4 = new java.lang.String;
        r4.<init>(r3);
        r3 = r4;
    L_0x0149:
        r3 = r1.get(r3);
        r3 = (java.lang.reflect.Method) r3;
        if (r3 == 0) goto L_0x004d;
    L_0x0151:
        r3 = "Bytes";
        r3 = r6.endsWith(r3);
        if (r3 == 0) goto L_0x017d;
    L_0x0159:
        r3 = r6.length();
        r3 = r3 + -5;
        r3 = r6.substring(r5, r3);
        r3 = java.lang.String.valueOf(r3);
        r4 = r3.length();
        if (r4 == 0) goto L_0x0172;
    L_0x016d:
        r3 = r7.concat(r3);
        goto L_0x0177;
    L_0x0172:
        r3 = new java.lang.String;
        r3.<init>(r7);
    L_0x0177:
        r3 = r0.containsKey(r3);
        if (r3 != 0) goto L_0x004d;
    L_0x017d:
        r3 = r6.substring(r5, r10);
        r3 = r3.toLowerCase();
        r3 = java.lang.String.valueOf(r3);
        r4 = r6.substring(r10);
        r4 = java.lang.String.valueOf(r4);
        r8 = r4.length();
        if (r8 == 0) goto L_0x019c;
    L_0x0197:
        r3 = r3.concat(r4);
        goto L_0x01a2;
    L_0x019c:
        r4 = new java.lang.String;
        r4.<init>(r3);
        r3 = r4;
    L_0x01a2:
        r4 = r6.length();
        if (r4 == 0) goto L_0x01ad;
    L_0x01a8:
        r4 = r7.concat(r6);
        goto L_0x01b2;
    L_0x01ad:
        r4 = new java.lang.String;
        r4.<init>(r7);
    L_0x01b2:
        r4 = r0.get(r4);
        r4 = (java.lang.reflect.Method) r4;
        r8 = "has";
        r9 = r6.length();
        if (r9 == 0) goto L_0x01c5;
    L_0x01c0:
        r6 = r8.concat(r6);
        goto L_0x01ca;
    L_0x01c5:
        r6 = new java.lang.String;
        r6.<init>(r8);
    L_0x01ca:
        r6 = r0.get(r6);
        r6 = (java.lang.reflect.Method) r6;
        if (r4 == 0) goto L_0x004d;
    L_0x01d2:
        r8 = new java.lang.Object[r5];
        r4 = c.e.a.b.e.c.u4.p(r4, r13, r8);
        if (r6 != 0) goto L_0x0252;
    L_0x01da:
        r6 = r4 instanceof java.lang.Boolean;
        if (r6 == 0) goto L_0x01e8;
    L_0x01de:
        r6 = r4;
        r6 = (java.lang.Boolean) r6;
        r6 = r6.booleanValue();
        if (r6 != 0) goto L_0x024c;
    L_0x01e7:
        goto L_0x024a;
    L_0x01e8:
        r6 = r4 instanceof java.lang.Integer;
        if (r6 == 0) goto L_0x01f6;
    L_0x01ec:
        r6 = r4;
        r6 = (java.lang.Integer) r6;
        r6 = r6.intValue();
        if (r6 != 0) goto L_0x024c;
    L_0x01f5:
        goto L_0x024a;
    L_0x01f6:
        r6 = r4 instanceof java.lang.Float;
        if (r6 == 0) goto L_0x0207;
    L_0x01fa:
        r6 = r4;
        r6 = (java.lang.Float) r6;
        r6 = r6.floatValue();
        r8 = 0;
        r6 = (r6 > r8 ? 1 : (r6 == r8 ? 0 : -1));
        if (r6 != 0) goto L_0x024c;
    L_0x0206:
        goto L_0x024a;
    L_0x0207:
        r6 = r4 instanceof java.lang.Double;
        if (r6 == 0) goto L_0x0219;
    L_0x020b:
        r6 = r4;
        r6 = (java.lang.Double) r6;
        r8 = r6.doubleValue();
        r11 = 0;
        r6 = (r8 > r11 ? 1 : (r8 == r11 ? 0 : -1));
        if (r6 != 0) goto L_0x024c;
    L_0x0218:
        goto L_0x024a;
    L_0x0219:
        r6 = r4 instanceof java.lang.String;
        if (r6 == 0) goto L_0x0224;
    L_0x021d:
        r6 = "";
        r6 = r4.equals(r6);
        goto L_0x024d;
    L_0x0224:
        r6 = r4 instanceof c.e.a.b.e.c.t3;
        if (r6 == 0) goto L_0x022f;
    L_0x0228:
        r6 = c.e.a.b.e.c.t3.b;
        r6 = r4.equals(r6);
        goto L_0x024d;
    L_0x022f:
        r6 = r4 instanceof c.e.a.b.e.c.e6;
        if (r6 == 0) goto L_0x023d;
    L_0x0233:
        r6 = r4;
        r6 = (c.e.a.b.e.c.e6) r6;
        r6 = r6.g();
        if (r4 != r6) goto L_0x024c;
    L_0x023c:
        goto L_0x024a;
    L_0x023d:
        r6 = r4 instanceof java.lang.Enum;
        if (r6 == 0) goto L_0x024c;
    L_0x0241:
        r6 = r4;
        r6 = (java.lang.Enum) r6;
        r6 = r6.ordinal();
        if (r6 != 0) goto L_0x024c;
    L_0x024a:
        r6 = 1;
        goto L_0x024d;
    L_0x024c:
        r6 = 0;
    L_0x024d:
        if (r6 != 0) goto L_0x0250;
    L_0x024f:
        goto L_0x025e;
    L_0x0250:
        r10 = 0;
        goto L_0x025e;
    L_0x0252:
        r8 = new java.lang.Object[r5];
        r6 = c.e.a.b.e.c.u4.p(r6, r13, r8);
        r6 = (java.lang.Boolean) r6;
        r10 = r6.booleanValue();
    L_0x025e:
        if (r10 == 0) goto L_0x004d;
    L_0x0260:
        r3 = w(r3);
        G(r14, r15, r3, r4);
        goto L_0x004d;
    L_0x0269:
        r0 = r13 instanceof c.e.a.b.e.c.u4.d;
        if (r0 == 0) goto L_0x028f;
    L_0x026d:
        r0 = r13;
        r0 = (c.e.a.b.e.c.u4.d) r0;
        r0 = r0.zzc;
        r0 = r0.l();
        r1 = r0.hasNext();
        if (r1 != 0) goto L_0x027d;
    L_0x027c:
        goto L_0x028f;
    L_0x027d:
        r13 = r0.next();
        r13 = (java.util.Map.Entry) r13;
        r13 = r13.getKey();
        r13 = (c.e.a.b.e.c.u4.c) r13;
        r13 = new java.lang.NoSuchMethodError;
        r13.<init>();
        throw r13;
    L_0x028f:
        r13 = (c.e.a.b.e.c.u4) r13;
        r13 = r13.zzb;
        if (r13 == 0) goto L_0x02ac;
    L_0x0295:
        r0 = r13.a;
        if (r5 >= r0) goto L_0x02ac;
    L_0x0299:
        r0 = r13.b;
        r0 = r0[r5];
        r0 = r0 >>> r4;
        r0 = java.lang.String.valueOf(r0);
        r1 = r13.c;
        r1 = r1[r5];
        G(r14, r15, r0, r1);
        r5 = r5 + 1;
        goto L_0x0295;
    L_0x02ac:
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.b.b.j.d.D(c.e.a.b.e.c.e6, java.lang.StringBuilder, int):void");
    }

    public static void E(q3 q3Var, SQLiteDatabase sQLiteDatabase) {
        if (q3Var != null) {
            File file = new File(sQLiteDatabase.getPath());
            if (!file.setReadable(false, false)) {
                q3Var.i.a("Failed to turn off database read permission");
            }
            if (!file.setWritable(false, false)) {
                q3Var.i.a("Failed to turn off database write permission");
            }
            if (!file.setReadable(true, true)) {
                q3Var.i.a("Failed to turn on database read permission for owner");
            }
            if (!file.setWritable(true, true)) {
                q3Var.i.a("Failed to turn on database write permission for owner");
                return;
            }
            return;
        }
        throw new IllegalArgumentException("Monitor must not be null");
    }

    public static void F(q3 q3Var, SQLiteDatabase sQLiteDatabase, String str, String str2, String str3, String[] strArr) throws SQLiteException {
        if (q3Var != null) {
            boolean moveToFirst;
            Cursor cursor = null;
            int i = 0;
            try {
                SQLiteDatabase sQLiteDatabase2 = sQLiteDatabase;
                cursor = sQLiteDatabase2.query("SQLITE_MASTER", new String[]{RankingConst.RANKING_JGW_NAME}, "name=?", new String[]{str}, null, null, null);
                moveToFirst = cursor.moveToFirst();
                cursor.close();
            } catch (SQLiteException e) {
                q3Var.i.c("Error querying for table", str, e);
                moveToFirst = false;
            } finally {
                if (cursor != null) {
                    cursor.close();
                }
            }
            if (!moveToFirst) {
                sQLiteDatabase.execSQL(str2);
            }
            try {
                Set y = y(sQLiteDatabase, str);
                String[] split = str3.split(",");
                int length = split.length;
                int i2 = 0;
                while (i2 < length) {
                    Object obj = split[i2];
                    if (((HashSet) y).remove(obj)) {
                        i2++;
                    } else {
                        StringBuilder stringBuilder = new StringBuilder((str.length() + 35) + String.valueOf(obj).length());
                        stringBuilder.append("Table ");
                        stringBuilder.append(str);
                        stringBuilder.append(" is missing required column: ");
                        stringBuilder.append(obj);
                        throw new SQLiteException(stringBuilder.toString());
                    }
                }
                if (strArr != null) {
                    while (i < strArr.length) {
                        if (!((HashSet) y).remove(strArr[i])) {
                            sQLiteDatabase.execSQL(strArr[i + 1]);
                        }
                        i += 2;
                    }
                }
                if (!((HashSet) y).isEmpty()) {
                    q3Var.i.c("Table has extra columns. table, columns", str, TextUtils.join(", ", y));
                    return;
                }
                return;
            } catch (SQLiteException e2) {
                q3Var.f.b("Failed to verify columns on table that was just created", str);
                throw e2;
            }
        }
        throw new IllegalArgumentException("Monitor must not be null");
    }

    public static final void G(StringBuilder stringBuilder, int i, String str, Object obj) {
        if (obj instanceof List) {
            for (Object G : (List) obj) {
                G(stringBuilder, i, str, G);
            }
        } else if (obj instanceof Map) {
            for (Entry G2 : ((Map) obj).entrySet()) {
                G(stringBuilder, i, str, G2);
            }
        } else {
            stringBuilder.append(10);
            int i2 = 0;
            for (int i3 = 0; i3 < i; i3++) {
                stringBuilder.append(' ');
            }
            stringBuilder.append(str);
            String str2 = ": \"";
            if (obj instanceof String) {
                stringBuilder.append(str2);
                String str3 = (String) obj;
                t3 t3Var = t3.b;
                stringBuilder.append(v(new z3(str3.getBytes(w4.a))));
                stringBuilder.append('\"');
            } else if (obj instanceof t3) {
                stringBuilder.append(str2);
                stringBuilder.append(v((t3) obj));
                stringBuilder.append('\"');
            } else {
                String str4 = "}";
                str2 = "\n";
                String str5 = " {";
                if (obj instanceof u4) {
                    stringBuilder.append(str5);
                    D((u4) obj, stringBuilder, i + 2);
                    stringBuilder.append(str2);
                    while (i2 < i) {
                        stringBuilder.append(' ');
                        i2++;
                    }
                    stringBuilder.append(str4);
                } else if (obj instanceof Entry) {
                    stringBuilder.append(str5);
                    Entry entry = (Entry) obj;
                    int i4 = i + 2;
                    G(stringBuilder, i4, "key", entry.getKey());
                    G(stringBuilder, i4, "value", entry.getValue());
                    stringBuilder.append(str2);
                    while (i2 < i) {
                        stringBuilder.append(' ');
                        i2++;
                    }
                    stringBuilder.append(str4);
                } else {
                    stringBuilder.append(": ");
                    stringBuilder.append(obj.toString());
                }
            }
        }
    }

    public static boolean H(byte b) {
        return b >= (byte) 0;
    }

    public static boolean I(@NullableDecl Object obj, @NullableDecl Object obj2) {
        return obj == obj2 || (obj != null && obj.equals(obj2));
    }

    public static int J(byte[] bArr, int i, s3 s3Var) {
        int i2 = i + 1;
        long j = (long) bArr[i];
        if (j >= 0) {
            s3Var.b = j;
            return i2;
        }
        j &= 127;
        i = i2 + 1;
        byte b = bArr[i2];
        j |= ((long) (b & 127)) << 7;
        int i3 = 7;
        while (b < (byte) 0) {
            i2 = i + 1;
            byte b2 = bArr[i];
            i3 += 7;
            j |= ((long) (b2 & 127)) << i3;
            int i4 = i2;
            b = b2;
            i = i4;
        }
        s3Var.b = j;
        return i;
    }

    public static long K(byte[] bArr, int i) {
        return ((((long) bArr[i + 7]) & 255) << 56) | (((((((((long) bArr[i]) & 255) | ((((long) bArr[i + 1]) & 255) << 8)) | ((((long) bArr[i + 2]) & 255) << 16)) | ((((long) bArr[i + 3]) & 255) << 24)) | ((((long) bArr[i + 4]) & 255) << 32)) | ((((long) bArr[i + 5]) & 255) << 40)) | ((((long) bArr[i + 6]) & 255) << 48));
    }

    public static <TResult> TResult L(g<TResult> gVar) throws ExecutionException {
        if (gVar.k()) {
            return gVar.h();
        }
        if (gVar.i()) {
            throw new CancellationException("Task is already canceled");
        }
        throw new ExecutionException(gVar.g());
    }

    public static void M(boolean z, @NullableDecl Object obj) {
        if (!z) {
            throw new IllegalStateException(String.valueOf(obj));
        }
    }

    public static int N(byte[] bArr, int i, s3 s3Var) throws e5 {
        i = p(bArr, i, s3Var);
        int i2 = s3Var.a;
        if (i2 < 0) {
            throw e5.b();
        } else if (i2 == 0) {
            s3Var.c = "";
            return i;
        } else {
            s3Var.c = new String(bArr, i, i2, w4.a);
            return i + i2;
        }
    }

    public static int O(byte[] bArr, int i, s3 s3Var) throws e5 {
        i = p(bArr, i, s3Var);
        int i2 = s3Var.a;
        if (i2 < 0) {
            throw e5.b();
        } else if (i2 == 0) {
            s3Var.c = "";
            return i;
        } else {
            s3Var.c = m7.a.c(bArr, i, i2);
            return i + i2;
        }
    }

    public static int P(byte[] bArr, int i, s3 s3Var) throws e5 {
        i = p(bArr, i, s3Var);
        int i2 = s3Var.a;
        if (i2 < 0) {
            throw e5.b();
        } else if (i2 > bArr.length - i) {
            throw e5.a();
        } else if (i2 == 0) {
            s3Var.c = t3.b;
            return i;
        } else {
            s3Var.c = t3.f(bArr, i, i2);
            return i + i2;
        }
    }

    public static boolean Q(byte b) {
        return b > (byte) -65;
    }

    public static <TResult> TResult a(g<TResult> gVar, long j, TimeUnit timeUnit) throws ExecutionException, InterruptedException, TimeoutException {
        f.P("Must not be called on the main application thread");
        f.S(gVar, "Task must not be null");
        f.S(timeUnit, "TimeUnit must not be null");
        if (gVar.j()) {
            return L(gVar);
        }
        j jVar = new j(null);
        Executor executor = i.b;
        gVar.c(executor, jVar);
        gVar.b(executor, jVar);
        gVar.a(executor, jVar);
        if (jVar.a.await(j, timeUnit)) {
            return L(gVar);
        }
        throw new TimeoutException("Timed out waiting for Task");
    }

    public static <TResult> g<TResult> b(TResult tResult) {
        a0 a0Var = new a0();
        a0Var.n(tResult);
        return a0Var;
    }

    public static boolean c() {
        return VERSION.SDK_INT >= 26;
    }

    public static boolean d(Context context, int i) {
        String str = "com.google.android.gms";
        boolean z = false;
        if (!f(context, i, str)) {
            return false;
        }
        try {
            PackageInfo packageInfo = context.getPackageManager().getPackageInfo(str, 64);
            c.e.a.b.b.f a = c.e.a.b.b.f.a(context);
            Objects.requireNonNull(a);
            if (packageInfo != null) {
                if (!c.e.a.b.b.f.d(packageInfo, false)) {
                    if (c.e.a.b.b.f.d(packageInfo, true)) {
                        if (!e.a(a.a)) {
                            Log.w("GoogleSignatureVerifier", "Test-keys aren't accepted on this build.");
                        }
                    }
                }
                z = true;
            }
            return z;
        } catch (NameNotFoundException unused) {
            String str2 = "UidVerifier";
            if (Log.isLoggable(str2, 3)) {
                Log.d(str2, "Package manager can't find google play services package, defaulting to false");
            }
            return false;
        }
    }

    /* JADX WARNING: Missing exception handler attribute for start block: B:18:0x003d */
    /* JADX WARNING: Can't wrap try/catch for region: R(4:16|17|18|19) */
    public static synchronized boolean e(android.content.Context r4) {
        /*
        r0 = c.e.a.b.b.j.d.class;
        monitor-enter(r0);
        r1 = r4.getApplicationContext();	 Catch:{ all -> 0x004b }
        r2 = d;	 Catch:{ all -> 0x004b }
        if (r2 == 0) goto L_0x0017;
    L_0x000b:
        r3 = e;	 Catch:{ all -> 0x004b }
        if (r3 == 0) goto L_0x0017;
    L_0x000f:
        if (r2 != r1) goto L_0x0017;
    L_0x0011:
        r4 = r3.booleanValue();	 Catch:{ all -> 0x004b }
        monitor-exit(r0);
        return r4;
    L_0x0017:
        r2 = 0;
        e = r2;	 Catch:{ all -> 0x004b }
        r2 = c();	 Catch:{ all -> 0x004b }
        if (r2 == 0) goto L_0x002f;
    L_0x0020:
        r4 = r1.getPackageManager();	 Catch:{ all -> 0x004b }
        r4 = r4.isInstantApp();	 Catch:{ all -> 0x004b }
        r4 = java.lang.Boolean.valueOf(r4);	 Catch:{ all -> 0x004b }
        e = r4;	 Catch:{ all -> 0x004b }
        goto L_0x0041;
    L_0x002f:
        r4 = r4.getClassLoader();	 Catch:{ ClassNotFoundException -> 0x003d }
        r2 = "com.google.android.instantapps.supervisor.InstantAppsRuntime";
        r4.loadClass(r2);	 Catch:{ ClassNotFoundException -> 0x003d }
        r4 = java.lang.Boolean.TRUE;	 Catch:{ ClassNotFoundException -> 0x003d }
        e = r4;	 Catch:{ ClassNotFoundException -> 0x003d }
        goto L_0x0041;
    L_0x003d:
        r4 = java.lang.Boolean.FALSE;	 Catch:{ all -> 0x004b }
        e = r4;	 Catch:{ all -> 0x004b }
    L_0x0041:
        d = r1;	 Catch:{ all -> 0x004b }
        r4 = e;	 Catch:{ all -> 0x004b }
        r4 = r4.booleanValue();	 Catch:{ all -> 0x004b }
        monitor-exit(r0);
        return r4;
    L_0x004b:
        r4 = move-exception;
        monitor-exit(r0);
        throw r4;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.b.b.j.d.e(android.content.Context):boolean");
    }

    @TargetApi(19)
    public static boolean f(Context context, int i, String str) {
        a a = b.a(context);
        Objects.requireNonNull(a);
        try {
            ((AppOpsManager) a.a.getSystemService("appops")).checkPackage(i, str);
            return true;
        } catch (SecurityException unused) {
            return false;
        }
    }

    public static g<Void> g(Collection<? extends g<?>> collection) {
        if (collection.isEmpty()) {
            return b(null);
        }
        for (g requireNonNull : collection) {
            Objects.requireNonNull(requireNonNull, "null tasks are not accepted");
        }
        a0 a0Var = new a0();
        k kVar = new k(collection.size(), a0Var);
        for (g gVar : collection) {
            Executor executor = i.b;
            gVar.c(executor, kVar);
            gVar.b(executor, kVar);
            gVar.a(executor, kVar);
        }
        return a0Var;
    }

    public static int h(int i, byte[] bArr, int i2, int i3, s3 s3Var) throws e5 {
        if ((i >>> 3) != 0) {
            int i4 = i & 7;
            if (i4 == 0) {
                return J(bArr, i2, s3Var);
            }
            if (i4 == 1) {
                return i2 + 8;
            }
            if (i4 == 2) {
                return p(bArr, i2, s3Var) + s3Var.a;
            }
            if (i4 == 3) {
                i = (i & -8) | 4;
                i4 = 0;
                while (i2 < i3) {
                    i2 = p(bArr, i2, s3Var);
                    i4 = s3Var.a;
                    if (i4 == i) {
                        break;
                    }
                    i2 = h(i4, bArr, i2, i3, s3Var);
                }
                if (i2 <= i3 && r0 == i) {
                    return i2;
                }
                throw e5.d();
            } else if (i4 == 5) {
                return i2 + 4;
            } else {
                throw e5.c();
            }
        }
        throw e5.c();
    }

    public static int i(int i, byte[] bArr, int i2, int i3, b5<?> b5Var, s3 s3Var) {
        x4 x4Var = (x4) b5Var;
        i2 = p(bArr, i2, s3Var);
        x4Var.e(s3Var.a);
        while (i2 < i3) {
            int p = p(bArr, i2, s3Var);
            if (i != s3Var.a) {
                break;
            }
            i2 = p(bArr, p, s3Var);
            x4Var.e(s3Var.a);
        }
        return i2;
    }

    public static int j(int i, byte[] bArr, int i2, int i3, e7 e7Var, s3 s3Var) throws e5 {
        if ((i >>> 3) != 0) {
            int i4 = i & 7;
            if (i4 == 0) {
                int J = J(bArr, i2, s3Var);
                e7Var.a(i, Long.valueOf(s3Var.b));
                return J;
            } else if (i4 == 1) {
                e7Var.a(i, Long.valueOf(K(bArr, i2)));
                return i2 + 8;
            } else if (i4 == 2) {
                i2 = p(bArr, i2, s3Var);
                i3 = s3Var.a;
                if (i3 < 0) {
                    throw e5.b();
                } else if (i3 <= bArr.length - i2) {
                    if (i3 == 0) {
                        e7Var.a(i, t3.b);
                    } else {
                        e7Var.a(i, t3.f(bArr, i2, i3));
                    }
                    return i2 + i3;
                } else {
                    throw e5.a();
                }
            } else if (i4 == 3) {
                e7 c = e7.c();
                int i5 = (i & -8) | 4;
                i4 = 0;
                while (i2 < i3) {
                    int p = p(bArr, i2, s3Var);
                    i2 = s3Var.a;
                    if (i2 == i5) {
                        i4 = i2;
                        i2 = p;
                        break;
                    }
                    i4 = i2;
                    i2 = j(i2, bArr, p, i3, c, s3Var);
                }
                if (i2 > i3 || r0 != i5) {
                    throw e5.d();
                }
                e7Var.a(i, c);
                return i2;
            } else if (i4 == 5) {
                e7Var.a(i, Integer.valueOf(o(bArr, i2)));
                return i2 + 4;
            } else {
                throw e5.c();
            }
        }
        throw e5.c();
    }

    public static int k(int i, byte[] bArr, int i2, s3 s3Var) {
        i &= 127;
        int i3 = i2 + 1;
        byte b = bArr[i2];
        if (b >= (byte) 0) {
            s3Var.a = i | (b << 7);
            return i3;
        }
        i |= (b & 127) << 7;
        i2 = i3 + 1;
        byte b2 = bArr[i3];
        if (b2 >= (byte) 0) {
            s3Var.a = i | (b2 << 14);
            return i2;
        }
        i |= (b2 & 127) << 14;
        i3 = i2 + 1;
        b = bArr[i2];
        if (b >= (byte) 0) {
            s3Var.a = i | (b << 21);
            return i3;
        }
        i |= (b & 127) << 21;
        i2 = i3 + 1;
        b2 = bArr[i3];
        if (b2 >= (byte) 0) {
            s3Var.a = i | (b2 << 28);
            return i2;
        }
        i |= (b2 & 127) << 28;
        while (true) {
            i3 = i2 + 1;
            if (bArr[i2] >= (byte) 0) {
                s3Var.a = i;
                return i3;
            }
            i2 = i3;
        }
    }

    public static int l(s6<?> s6Var, int i, byte[] bArr, int i2, int i3, b5<?> b5Var, s3 s3Var) throws IOException {
        i2 = n(s6Var, bArr, i2, i3, s3Var);
        b5Var.add(s3Var.c);
        while (i2 < i3) {
            int p = p(bArr, i2, s3Var);
            if (i != s3Var.a) {
                break;
            }
            i2 = n(s6Var, bArr, p, i3, s3Var);
            b5Var.add(s3Var.c);
        }
        return i2;
    }

    public static int m(s6 s6Var, byte[] bArr, int i, int i2, int i3, s3 s3Var) throws IOException {
        g6 g6Var = (g6) s6Var;
        Object a = g6Var.k.a(g6Var.e);
        int l = g6Var.l(a, bArr, i, i2, i3, s3Var);
        g6Var.d(a);
        s3Var.c = a;
        return l;
    }

    public static int n(s6 s6Var, byte[] bArr, int i, int i2, s3 s3Var) throws IOException {
        int i3 = i + 1;
        i = bArr[i];
        if (i < 0) {
            i3 = k(i, bArr, i3, s3Var);
            i = s3Var.a;
        }
        int i4 = i3;
        if (i < 0 || i > i2 - i4) {
            throw e5.a();
        }
        Object q = s6Var.q();
        i += i4;
        s6Var.g(q, bArr, i4, i, s3Var);
        s6Var.d(q);
        s3Var.c = q;
        return i;
    }

    public static int o(byte[] bArr, int i) {
        return ((bArr[i + 3] & ISdkLite.REGION_UNSET) << 24) | (((bArr[i] & ISdkLite.REGION_UNSET) | ((bArr[i + 1] & ISdkLite.REGION_UNSET) << 8)) | ((bArr[i + 2] & ISdkLite.REGION_UNSET) << 16));
    }

    public static int p(byte[] bArr, int i, s3 s3Var) {
        int i2 = i + 1;
        byte b = bArr[i];
        if (b < (byte) 0) {
            return k(b, bArr, i2, s3Var);
        }
        s3Var.a = b;
        return i2;
    }

    public static int q(byte[] bArr, int i, b5<?> b5Var, s3 s3Var) throws IOException {
        x4 x4Var = (x4) b5Var;
        i = p(bArr, i, s3Var);
        int i2 = s3Var.a + i;
        while (i < i2) {
            i = p(bArr, i, s3Var);
            x4Var.e(s3Var.a);
        }
        if (i == i2) {
            return i;
        }
        throw e5.a();
    }

    public static <T> z2<T> r(z2<T> z2Var) {
        if ((z2Var instanceof c3) || (z2Var instanceof a3)) {
            return z2Var;
        }
        if (z2Var instanceof Serializable) {
            return new a3(z2Var);
        }
        return new c3(z2Var);
    }

    public static <T> T s(Bundle bundle, String str, Class<T> cls, T t) {
        Object obj = bundle.get(str);
        if (obj == null) {
            return t;
        }
        if (cls.isAssignableFrom(obj.getClass())) {
            return obj;
        }
        throw new IllegalStateException(String.format("Invalid conditional user property field type. '%s' expected [%s] but was [%s]", new Object[]{str, cls.getCanonicalName(), obj.getClass().getCanonicalName()}));
    }

    public static <V> V t(d2<V> d2Var) {
        long clearCallingIdentity;
        d2 d2Var2;
        try {
            d2Var2 = d2Var2.q();
            return d2Var2;
        } catch (SecurityException unused) {
            clearCallingIdentity = Binder.clearCallingIdentity();
            V q = d2Var2.q();
            return q;
        } finally {
            Binder.restoreCallingIdentity(clearCallingIdentity);
        }
    }

    public static String u(Context context, String str) {
        try {
            Objects.requireNonNull(context, "null reference");
            Resources resources = context.getResources();
            int identifier = resources.getIdentifier(str, "string", resources.getResourcePackageName(2131689759));
            return identifier == 0 ? null : resources.getString(identifier);
        } catch (NotFoundException unused) {
        }
    }

    public static String v(t3 t3Var) {
        StringBuilder stringBuilder = new StringBuilder(t3Var.c());
        for (int i = 0; i < t3Var.c(); i++) {
            byte b = t3Var.b(i);
            if (b == (byte) 34) {
                stringBuilder.append("\\\"");
            } else if (b == (byte) 39) {
                stringBuilder.append("\\'");
            } else if (b != (byte) 92) {
                switch (b) {
                    case (byte) 7:
                        stringBuilder.append("\\a");
                        break;
                    case (byte) 8:
                        stringBuilder.append("\\b");
                        break;
                    case (byte) 9:
                        stringBuilder.append("\\t");
                        break;
                    case (byte) 10:
                        stringBuilder.append("\\n");
                        break;
                    case (byte) 11:
                        stringBuilder.append("\\v");
                        break;
                    case (byte) 12:
                        stringBuilder.append("\\f");
                        break;
                    case (byte) 13:
                        stringBuilder.append("\\r");
                        break;
                    default:
                        if (b >= (byte) 32 && b <= (byte) 126) {
                            stringBuilder.append((char) b);
                            break;
                        }
                        stringBuilder.append('\\');
                        stringBuilder.append((char) (((b >>> 6) & 3) + 48));
                        stringBuilder.append((char) (((b >>> 3) & 7) + 48));
                        stringBuilder.append((char) ((b & 7) + 48));
                        break;
                        break;
                }
            } else {
                stringBuilder.append("\\\\");
            }
        }
        return stringBuilder.toString();
    }

    public static final String w(String str) {
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            char charAt = str.charAt(i);
            if (Character.isUpperCase(charAt)) {
                stringBuilder.append("_");
            }
            stringBuilder.append(Character.toLowerCase(charAt));
        }
        return stringBuilder.toString();
    }

    public static String x(String str, String[] strArr, String[] strArr2) {
        int min = Math.min(strArr.length, strArr2.length);
        for (int i = 0; i < min; i++) {
            Object obj = strArr[i];
            boolean equals = (str == null && obj == null) ? true : str == null ? false : str.equals(obj);
            if (equals) {
                return strArr2[i];
            }
        }
        return null;
    }

    public static Set<String> y(SQLiteDatabase sQLiteDatabase, String str) {
        HashSet hashSet = new HashSet();
        StringBuilder stringBuilder = new StringBuilder(String.valueOf(str).length() + 22);
        stringBuilder.append("SELECT * FROM ");
        stringBuilder.append(str);
        stringBuilder.append(" LIMIT 0");
        Cursor rawQuery = sQLiteDatabase.rawQuery(stringBuilder.toString(), null);
        try {
            Collections.addAll(hashSet, rawQuery.getColumnNames());
            return hashSet;
        } finally {
            rawQuery.close();
        }
    }

    public static void z(byte b, byte b2, byte b3, byte b4, char[] cArr, int i) throws e5 {
        if (!Q(b2)) {
            if (!((((b2 + 112) + (b << 28)) >> 30) != 0 || Q(b3) || Q(b4))) {
                int i2 = ((((b & 7) << 18) | ((b2 & 63) << 12)) | ((b3 & 63) << 6)) | (b4 & 63);
                cArr[i] = (char) ((i2 >>> 10) + 55232);
                cArr[i + 1] = (char) ((i2 & 1023) + 56320);
                return;
            }
        }
        throw e5.e();
    }
}
